import request from '@/utils/request'
/**
 * 查询字典项
 */
export function getDictByCode(dictCode) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysDictionary/getDictByCode',
    method: 'get',
    params: {
      dictCode
    }
  })
}
/**
 * 异步组织部门树
 */
export function getComAndOrgTree(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/queryOrgAndDep',
    method: 'post',
    data
  })
}
/**
 * 异步组织部门树
 */
export function getComLeaf(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getLeaf',
    method: 'post',
    data
  })
}

/**
 * 异步new企业部门树
 */
export function getNewTreeData(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/orgInfo/getOrgAndDepTreeByName',
    method: 'post',
    data
  })
}
/**
 * 查询角色树
 * @param {*} data
 */
export function roleList(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/role/queryPageRoles',
    method: 'post',
    data
  })
}
/**
 * 查询模块权限树
 */
export function queryMenu(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/menu/queryMenu',
    method: 'post',
    data
  })
}
/**
 * 获取角色对应用户列表
 * @param {*} data
 */
export function userList(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/queryRoleUser',
    method: 'post',
    data
  })
}
/**
 * 删除角色权限用户
 * @param {*} ids
 * @param {*} roleId
 */
export function deleteUser(ids, roleId) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/deleteRoleUser',
    method: 'get',
    params: {
      ids,
      roleId
    }
  })
}
/**
 * 为角色添加用户
 * @param {*} roleId
 * @param {*} userIds
 */
export function insertRoleUser(roleId, userIds) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/insertRoleUser',
    method: 'get',
    params: {
      roleId,
      userIds
    }
  })
}
/**
 * 查询角色列表
 * @param {*} data
 */
export function queryUserRole(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysUserLogin/queryPage',
    method: 'post',
    data
  })
}
